{{csrf_field()}}

<div style="padding:30px 30px 30px 20px" class="layui-form">
    <div class="layui-form-item">
        <label class="layui-form-label">品牌名称：</label>
        <div class="layui-input-block">
            <input type="text" name="name" value="{{$info->name?? ''}}" id="name"  lay-verify="required"  lay-reqText="品牌名称必填" placeholder="请输入参数名称" autocomplete="off" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">品牌链接：</label>
        <div class="layui-input-block">
            <input type="text" name="links" value="{{$info->links?? ''}}" id="links" placeholder="链接地址" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label ">品牌Logo：</label>
        <div class="layui-input-block">
            <button type="button"  class="layui-btn upload-image">上传图片</button>
            <div class="layui-upload-list">

                @if(isset($info->logo) && !empty($info->logo))
                    <img class="layui-upload-img" src="{{$info->logo?? ''}}" style="width: 90px" >
                @else
                    <img class="layui-upload-img" style="width: 90px" >
                @endif
                <input type="hidden" name="logo" value="{{$info->logo?? ''}}">
            </div>

        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">排序：</label>
        <div class="layui-input-block">
            <input type="number" name="sort" value="{{$info->sort?? ''}}" id="sort" lay-verify="required" placeholder="越小越大" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-fluid"  lay-submit lay-filter="popup-save" >保 存</button>
        </div>
    </div>
  </div>
<textarea id="edit_image" style="display: none;"></textarea>
<script>
    layui.use(['layer', 'form','jquery'], function(){
        var layer = layui.layer,
            $  = layui.jquery;

        var _editor = UE.getEditor("edit_image",{
            initialFrameWidth:800,
            initialFrameHeight:300,
            zIndex:19891026,
        });
        _editor.ready(function (){
            _editor.hide();
            _editor.addListener('beforeInsertImage',function(t,arg){
                console.log(arg);
                console.log(t);
                var obj = _editor.queryCommandValue("serverparam");
                if(obj.type == "upload-image"){
                    if(arg.length>1){
                        layer.msg("最多只能选择1张图片，请重新选择");
                        return false;
                    }
                    if(arg.length>0) {
                        var uploadImageTd = obj.uploadImageItem.parent().find(".layui-upload-list");
                        console.log(uploadImageTd);
                        uploadImageTd.find('img').attr('src',arg[0].src);
                        uploadImageTd.find('input').val(arg[0].image_id);
                        uploadImageTd.show();
                    }else{
                        layer.msg("请先选择图片");
                        return false;
                    }
                }
                return true;
            });
        });

        $("body").on("click", ".upload-image", function () {

            //此处进行初始化
            var obj = _editor.queryCommandValue("serverparam");
            obj.type = "upload-image";
            obj.uploadImageItem = $(this);
            var uploadImage = _editor.getDialog("insertimage");
            console.log(obj);
            uploadImage.open();
        });

    });
</script>

